C NOTE: Read the "MPW Fortrans" section of "About Compilers"
C before compiling AF programs that use FaceWare modules.

C FaceIt 2.2 Demonstration Program
C ©FaceWare 1989-93.  All Rights Reserved.
C1 - run program to see on-line comments

	GLOBAL DEFINE
	include "Types.inc"
	include "QuickDraw.inc"
	include "ToolUtils.inc"
	include "Controls.inc"
	include "Events.inc"
	include "OSUtils.inc"
	include "OSEvents.inc"
	include "SegLoad.inc"
	include "Files.inc"
	include "Resources.inc"
	include "FaceStorAF.inc"
	END
C2
	include "FaceProcAF.inc"

      PROGRAM fDemoAF
	implicit none
      record /FaceRec/ fRec
      common/FaceStuff/fRec
	integer*1 keys(16)
	integer*2 mode
	integer*4 oldCount,newCount
	character*256 fileName
C3
      fRec.uName = 'fDemo.Rsrc'
C4
      call FaceIt(0,DoInit,3,0,0,0)
C5
	call FaceIt(0,NewWnd,1010,1,0,0)
	call FaceIt(0,NewWnd,1020,1,0,0)
C6
	call FaceIt(0,NewWnd,1030,1,0,0)
C7
	call FaceIt(0,NewWnd,1040,2,0,0)
C8
      do while (.true.)
        call FaceIt(0,DoLoop,0,0,0,0)
C9
C10
        if (fRec.uMenuID == 101) then
	    if (fRec.uMenuItem == 1) then
	      fRec.uString = 'Demonstration of the use of FaceIt'
     +//char(13)//'to support program-wide features.'
	      call FaceIt(0,ShoStr,3,12,(1 + (409*65536)),0)
	    end if
C11
	  else if (fRec.uMenuID == 102) then
	    if (fRec.uMenuItem == 6) then
	      call FaceIt(0,GetWVC,1010,0,0,0)
	      call FaceIt(0,SavWnd,1010,0,0,0)
	      call FaceIt(0,GetWVC,1020,0,0,0)
	      call FaceIt(0,SavWnd,1020,0,0,0)
	      call FaceIt(0,GetWVC,1040,0,0,0)
	      call FaceIt(0,SavWnd,1040,0,0,0)
	    end if
C12
	  else if ((fRec.uMenuID >= 105).and.(fRec.uMenuID <= 1040)) then
	    if (fRec.uMenuItem == 1) then
	      call SysBeep(%val2(5))
	    else if (fRec.uMenuItem == 2) then
	      call SysBeep(%val2(5))
	      call SysBeep(%val2(5))
	    else if (fRec.uMenuItem == 3) then
	      call SysBeep(%val2(5))
	      call SysBeep(%val2(5))
	      call SysBeep(%val2(5))
C13
	    else if (fRec.uMenuItem == 4) then
	      call FaceIt(0,GetCtl,1030,0,1,4)
	      call FaceIt(0,PopMen,107,fRec.cRect(1)-9,fRec.cRect(2)-10,0)
C14
	    else if (fRec.uMenuItem == 8) then
C15
		call FaceIt(0,ShoAlt,1010,0,1,1)
		mode = fRec.uResult
		oldCount = 0
		if (mode > 1) then
		  do while (.true.)
C16
		    newCount = TickCount()
		    if (newCount - oldCount > 180) then
		      call SysBeep(%val2(5))
			oldCount = newCount
		    end if
C17
		    if (mode == 2) then
		      if (GetNextEvent(%val2(-1),fRec.fEvent) <> 0) then
			  if (fRec.fEvent(1) == 5) then
			    exit
			  else
			    call FaceIt(0,DoEvnt,0,0,0,0)
			  end if
			end if
		    end if
C18
		    if (mode == 3) then
		      call GetKeys(keys)
			if ((BitTst(keys,%val4(61))<>0)
     +		 .and.(BitTst(keys,%val4(48))<>0)) then
			  call FlushEvents(%val2(62),%val2(0))
			  exit
			end if
		    end if
		  end do
		end if
	    end if
C19
	  else if (fRec.uMenuID == 1100) then
	    if (fRec.uMenuItem == 2) then
	      if (fRec.fActiveWnd == 0) then
		  fRec.uString = 'No Window'
		else if (fRec.fActiveID <> 1200) then
		  fRec.uString = 'Non-ViewIt Window'
		else if (fRec.fActiveResID == 1204) then
		  fRec.uString = 'Help Window'
		else if (fRec.fActiveResID == 1010) then
		  fRec.uString = 'Editor Window'
		else if (fRec.fActiveResID == 1020) then
		  fRec.uString = 'Clipboard Window'
		else if (fRec.fActiveResID == 1030) then
		  fRec.uString = 'Beeps Window'
		end if
		call FaceIt(0,SetItm2,105,10,3,0)
C20
	    else if (fRec.uMenuItem == 512) then
	      if ((fRec.uString == 'TEXT').and.(fRec.uResult == 1)) then
		  fileName = fRec.uName
		  call FaceIt(0,GetCtl,1010,0,1,1)
		  fRec.uName = fileName
		  call FaceIt(fRec.cControl,1551,0,1,0,0) !OpnCTxt
		end if
	    end if
	  end if
      end do
      end
